/*
    文件内容: EchoServer类,业务类,回显服务器类
    文件名: EchoServer.h
    作者: 中国好青年(码农论坛)
    时间: 2024/9/15
*/
#pragma once

#include "TcpServer.h"
#include "ThreadPool.h"
#include <unistd.h>
#include <sys/syscall.h>   /* For SYS_xxx definitions */

class EchoServer
{
private:
    TcpServer tcpserver_;
    ThreadPool workthreadpool_;
public:
    EchoServer(const std::string &ip, const uint16_t port, int timeout, int pthreadnums, int workthreadnums);
    ~EchoServer();

    void Start();
    void Stop();

    void handleNewConnection(spConnection conn);
    void handleCloseConnection(spConnection conn);
    void handleErrorConnection(spConnection conn);
    void handleOnmessage(spConnection conn, std::string &message);
    void handleSendComplete(spConnection conn);
    void handleEpolltimeout(EventLoop *eploop);
    void onMessage(spConnection conn, std::string &message);
    
};